Skip to content

update tests #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2025
Merged

update tests #10

merged 2 commits into from
Feb 28, 2025

Conversation

dzencot
Copy link
Contributor

@dzencot dzencot commented Feb 28, 2025

No description provided.

@dzencot dzencot requested a review from fey February 28, 2025 06:52
@fey
Copy link
Contributor

fey commented Feb 28, 2025

@dzencot линтер упал.

const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
await import('./index.js')

const firstArg = consoleLogSpy.mock.calls.join('\n');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dzencot эта штука повторяется неск раз. Ее можно вынести в общий модуль?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У нас это уже выделено отдельно

const expectOutput = async (expected, run = (f) => f()) => {
но не работает на витесте, падает ошибка и пока с ней разобраться не удается, уже много времени на это потратил. Конечно могу это вынести. Думаю можно это даже попробовать через конфиг витеста сделать

const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
await import('./index.js')

const firstArg = consoleLogSpy.mock.calls[0]?.[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А в чем отличие от const firstArg = consoleLogSpy.mock.calls.join('\n');?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь берем именно что было передано в первый вызов console.log. при чем получаем не строковое значение, а тот тип, который был передан

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

окей, понял, вижу что в хелоу ворлде так сделано

@fey
Copy link
Contributor

fey commented Feb 28, 2025

@dzencot а чего jest не заменяешь в тестах, где надо проверить фуункции?
https://github.com/hexlet-basics/exercises-pre-course-javascript/blob/main/modules/50-loops/23-aggregation-strings/test.js - пример

@fey fey merged commit 6491f5b into main Feb 28, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants